{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('coupon');}">道具管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('coupon', array('op' => 'addShow'));}">添加道具</a></li>
</ul>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:60px;">id</th>
                <th style="width:60px;">道具名称</th>
                <th style="width:60px;">道具图标</th>
                <th style="width:80px;">延时天数</th>
                <th style="width:80px;">失效天数</th>
                <th style="width:80px;">积分</th>
                <th style="width:100px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $coupon['list'] $item}
            <tr>
                <td>{$item['id']}</td>
                <td>{$item['name']}</td>
                <td><img src="{php echo tomedia($item['icon'])}" width="39px" height="39px"></td>
                <td>{$item['worth']}</td>
                <td>{$item['validity']}</td>
                <td>{$item['integral']}</td>
                <td>
                    <a href="{php echo $this->createWeburl('coupon', array('op' => 'editShow', 'id' => $item['id']));}" class="btn btn-success btn-sm">编辑</a>&nbsp;
                    <a href="javascript:;" id="{$item['id']}" class="delete btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    {$coupon['pages']}
</div>
{template 'footer'}
<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除此道具?')) {
                return false;
            }
            id = $(this).attr('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });


        $('.sort').blur(function () {
            var sort = $(this).val();
            var  id = $(this).data('id');
            $.post('', {id:id,sort:sort, op:'sort'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('排序失败');
                }

            }, 'json')
        });

        $('.settop').click(function () {
            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });
    });

</script>